import request from '../../utils/request.js'
const state = {
	homeInfo:{},
	cardList:[]
}
const actions = {
	async getHomeInfoData({commit}){
		try{
			const result =await request({url:'/getIndexData'})
			commit('SET_HOME_INFO_DATA',result)
		}catch(e){
			console.log(e)
		}
	},
	async getHomeCardListData({commit}){
		try{
			const result = await request({url:'/getIndexCateList'})
			console.log('card',result)
			commit('SET_HOME_CARD_LIST_DATA',result)
		}catch(e){
			console.log(e.message)
		}
	}
}
const mutations = {
	SET_HOME_INFO_DATA(state,result){
		state.homeInfo = result
	},
	SET_HOME_CARD_LIST_DATA(state,arr){
		state.cardList = arr
	}
}
const getters = {
	
	navList(state){  
		return (state.homeInfo.kingKongModule || {}).kingKongList || []
	},
	sloganList(state){
		return state.homeInfo.policyDescList || []
	},

	floorsList(state){
		return state.homeInfo.categoryModule || []
	}
}

export default {
	namespaced: true, // 开启命名空间 也就是开启模块化的访问方式
	state,
	actions,
	mutations,
	getters
}